package com.example.demo.generator.controller;

import com.baomidou.mybatisplus.extension.api.R;
import com.example.demo.generator.entiy.TBuyorder;
import com.example.demo.generator.service.TBuyorderService;
import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.CrossOrigin;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

@RestController
@Api(tags="买单接口")
@CrossOrigin("*")
public class BuyOrderController {

    @Autowired
    private TBuyorderService tBuyorderService;

    @GetMapping("getlist")
    @ApiOperation("获取买单列表")
    public R getlist(@RequestParam(value = "pageNum",defaultValue = "")Integer pageNum,@RequestParam(value = "pageSize",defaultValue = "")Integer pageSize){
        if(pageNum!=null&&pageSize!=null){
            PageHelper.startPage(pageNum,pageSize);
            List<TBuyorder>tBuyorderList=tBuyorderService.list(null);
            PageInfo<TBuyorder>pageInfo=new PageInfo<>(tBuyorderList);
            return R.ok(pageInfo);
        }else{
            List<TBuyorder>tBuyorderList=tBuyorderService.list(null);
            return R.ok(tBuyorderList);
        }
    }
}
